# -*- coding: utf-8 -*-
#页面元素

from playwright.sync_api import Page
class LoginPage:

    def __init__(self, page: Page):
        self.page = page
        self.locator_username = page.get_by_placeholder("请输入账号")
        self.locator_password = page.get_by_role("textbox", name="请输入密码")
        self.locator_login_btn = page.get_by_role("button", name="登录")
        # 无效的账号
        self.locator_username_tip1 = page.get_by_role("alert")
        # 账号或密码不正确
        self.locator_password_tip1 = page.get_by_role("alert")


    def navigate(self):
        self.page.goto("http://192.168.7.136:3000/login?redirect=%2F")

    def fill_username(self, username):
        self.locator_username.fill(username)

    def fill_password(self, password):
        self.locator_password.fill(password)


    def click_login_button(self):
        self.locator_login_btn.click()
